import { Body, Controller, Get, Inject, Post, Query } from "@nestjs/common";
import { ApiOperation, ApiTags } from "@nestjs/swagger";
import { Result } from "src/common/Result";
import { GoodsDto } from "src/dto/GoodsDto";
import { StockDto } from "src/dto/StockDto";
import { StockService } from "src/service/StockService";

@ApiTags("库存模块")
@Controller("/stock")
export class StockController {

    @Inject()
    private stockService: StockService;
    
    /**
     * 库存列表查询
     * @param query goodsCode：商品编码
     */
    @ApiOperation({summary: "库存列表查询"})
    @Get("/selectUnitStock")
    async selectUnitStock(@Query() query: StockDto) {
        let data = await this.stockService.selectUnitStock(query);
        return Result.success("成功", data);
    }


    /**
     * 进货
     */
    @ApiOperation({summary: "进货"})
    @Post("/updateStock")
    async updateStock(@Body() dto: GoodsDto) {
        return await this.stockService.updateStock(dto);
    }
}